package chapter13.eg3;

import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class PerformanceApplication {

  public static void main(String[] args) {
    SpringApplication.run(PerformanceApplication.class, args);
    Executors.newScheduledThreadPool(1)
        .scheduleAtFixedRate(() -> {
          new Thread(() -> {
            for (int i = 0; i < 150; i++) {
              try {
                byte[] temp = new byte[512 * 1024];
                Thread.sleep(new Random().nextInt(1000));
              } catch (InterruptedException e) {
                e.printStackTrace();
              }
            }
          }).start();
        }, 100, 100, TimeUnit.MILLISECONDS);
  }

}
